(function(e){e.BX=e["BX"]||{};if(e.BX["UploaderQueue"])return false;var t=e.BX,i={new:0,ready:1,preparing:2,inprogress:3,done:4,failed:5,stopped:6,changed:7,uploaded:8};t.UploaderQueue=function(e,i,s){this.dialogName="BX.UploaderQueue";i=!!i?i:{};this.limits={phpPostMaxSize:i["phpPostMaxSize"],phpUploadMaxFilesize:i["phpUploadMaxFilesize"],uploadMaxFilesize:i["uploadMaxFilesize"]>0?i["uploadMaxFilesize"]:0,uploadFileWidth:i["uploadFileWidth"]>0?i["uploadFileWidth"]:0,uploadFileHeight:i["uploadFileHeight"]>0?i["uploadFileHeight"]:0};this.placeHolder=t(e["placeHolder"]);this.showImage=e["showImage"]!==false&&e["showImage"]!=="N";this.sortItems=e["sortItems"]!==false&&e["sortItems"]!=="N";this.fileCopies=e["copies"];this.fileFields=e["fields"];this.uploader=s;this.itForUpload=new t.UploaderUtils.Hash;this.items=new t.UploaderUtils.Hash;this.itUploaded=new t.UploaderUtils.Hash;this.itFailed=new t.UploaderUtils.Hash;this.thumb={tagName:"LI",className:"bx-bxu-thumb-thumb"};if(!!e["thumb"]){for(var r in e["thumb"]){if(e["thumb"].hasOwnProperty(r)&&this.thumb.hasOwnProperty(r)){this.thumb[r]=e["thumb"][r]}}}t.addCustomEvent(s,"onItemIsAdded",t.delegate(this.addItem,this));t.addCustomEvent(s,"onFileIsDeleted",t.delegate(this.deleteItem,this));t.addCustomEvent(s,"onFileIsReinited",t.delegate(this.reinitItem,this));this.log("Initialized");return this};t.UploaderQueue.prototype={showError:function(e){this.log("Error! "+e)},log:function(e){t.UploaderUtils.log("queue",e)},addItem:function(s,r){var d;if(!this.showImage)d=false;else if(t.type.isDomNode(s))d=t.UploaderUtils.isImage(s.value,null,null);else d=t.UploaderUtils.isImage(s["name"],s["type"],s["size"]);t.onCustomEvent(this.uploader,"onFileIsBeforeCreated",[s,r,d,this.uploader]);var a={copies:this.fileCopies,fields:this.fileFields},o=d?new t.UploaderImage(s,a,this.limits,this.uploader):new t.UploaderFile(s,a,this.limits,this.uploader),l,n,u={status:i.ready};t.onCustomEvent(o,"onFileIsAfterCreated",[o,r,u,this.uploader]);t.onCustomEvent(this.uploader,"onFileIsAfterCreated",[o,r,u,this.uploader]);this.items.setItem(o.id,o);if(r||u["status"]!==i.ready){this.itUploaded.setItem(o.id,o)}else{this.itForUpload.setItem(o.id,o)}if(!!this.placeHolder){if(t(r)){o.thumbNode=n=t(r);n.setAttribute("bx-bxu-item-id",o.id)}else{l=o.makeThumb();n=t.create(this.thumb.tagName,{attrs:{id:o.id+"Item","bx-bxu-item-id":o.id,className:this.thumb.className}});if(t.type.isNotEmptyString(l)){if(this.thumb.tagName=="TR"){l=l.replace(/[\n\t]/gi,"").replace(/^(\s+)(.*?)/gi,"$2").replace(/(.*?)(\s+)$/gi,"$1");if(!!l["trim"])l=l.trim();var h=function(e,t,i){var s=n.insertCell(-1),r={colspan:true,headers:true,accesskey:true,class:true,contenteditable:true,contextmenu:true,dir:true,hidden:true,id:true,lang:true,spellcheck:true,style:true,tabindex:true,title:true,translate:true},d;s.innerHTML=i;t=t.split(" ");while((d=t.pop())&&d){d=d.split("=");if(d.length==2){d[0]=d[0].replace(/^(\s+)(.*?)/gi,"$2").replace(/(.*?)(\s+)$/gi,"$1").replace(/^["'](.*?)["']$/gi,"$1");d[1]=d[1].replace(/^(\s+)(.*?)/gi,"$2").replace(/(.*?)(\s+)$/gi,"$1").replace(/^["'](.*?)["']$/gi,"$1");if(r[d[0]]===true)s.setAttribute(d[0],d[1]);else s[d[0]]=d[1]}}return""},p=/^<td(.*?)>(.*?)<\/td>/i;e.data1=l;while(p.test(l))l=l.replace(p,h)}else{n.innerHTML=l}}else if(t.type.isDomNode(l)){t.adjust(n,{children:[l]})}}if(!!e["jsDD"]&&this.sortItems){if(!this._onbxdragstart){this._onbxdragstart=t.delegate(this.onbxdragstart,this);this._onbxdragstop=t.delegate(this.onbxdragstop,this);this._onbxdrag=t.delegate(this.onbxdrag,this);this._onbxdraghout=t.delegate(this.onbxdraghout,this);this._onbxdestdraghover=t.delegate(this.onbxdestdraghover,this);this._onbxdestdraghout=t.delegate(this.onbxdestdraghout,this);this._onbxdestdragfinish=t.delegate(this.onbxdestdragfinish,this)}t.addClass(n,"bx-drag-draggable");n.onbxdragstart=this._onbxdragstart;n.onbxdragstop=this._onbxdragstop;n.onbxdrag=this._onbxdrag;n.onbxdraghout=this._onbxdraghout;e.jsDD.registerObject(n);n.onbxdestdraghover=this._onbxdestdraghover;n.onbxdestdraghout=this._onbxdestdraghout;n.onbxdestdragfinish=this._onbxdestdragfinish;e.jsDD.registerDest(n);var m=t.findChild(n,{tagName:"INPUT",props:{type:"text"}},true,true);for(var g=0;g<=m.length;g++){t.bind(m[g],"mousedown",t.eventCancelBubble)}}n.setAttribute("bx-item-id",o.id);if(t(r)){t.onCustomEvent(this.uploader,"onFileIsBound",[o.id,o,this.caller,r]);t.onCustomEvent(o,"onFileIsBound",[o.id,o,this.caller,r])}else if(!!r){this.placeHolder.appendChild(n);t.onCustomEvent(this.uploader,"onFileIsAttached",[o.id,o,this.caller,r]);t.onCustomEvent(o,"onFileIsAttached",[o.id,o,this.caller,r])}else{this.placeHolder.appendChild(n);t.onCustomEvent(this.uploader,"onFileIsAppended",[o.id,o,this.caller]);t.onCustomEvent(o,"onFileIsAppended",[o.id,o,this.caller])}}t.onCustomEvent(this.uploader,"onQueueIsChanged",[this,"add",o.id,o])},getItem:function(e){var i=this.items.getItem(e);if(i)return{item:i,node:i.thumbNode||t(e+"Item")};return null},onbxdragstart:function(){var e=t.proxy_context,i=e&&e.getAttribute("bx-item-id");if(i){var s=e.innerHTML.replace(new RegExp(i,"gi"),"DragCopy");e.__dragCopyDiv=t.create("DIV",{attrs:{className:"bx-drag-object "+e.className},style:{position:"absolute",zIndex:10,width:e.clientWidth+"px"},html:s});e.__dragCopyPos=t.pos(e);t.onCustomEvent(this.uploader,"onBxDragStart",[e,e.__dragCopyDiv]);document.body.appendChild(e.__dragCopyDiv);t.addClass(e,"bx-drag-source");var r=t("DragCopyProperCanvas"),d,a=this.items.getItem(i);if(r&&(a&&t(a.canvas))){d=a.canvas.cloneNode(true);r.parentNode.replaceChild(d,r);d.getContext("2d").drawImage(a.canvas,0,0)}}return true},onbxdragstop:function(){var e=t.proxy_context;if(e.__dragCopyDiv){t.removeClass(e,"bx-drag-source");e.__dragCopyDiv.parentNode.removeChild(e.__dragCopyDiv);e.__dragCopyDiv=null;delete e["__dragCopyDiv"];delete e["__dragCopyPos"]}return true},onbxdrag:function(e,i){var s=t.proxy_context,r=s.__dragCopyDiv;if(r){if(s.__dragCopyPos){if(!s.__dragCopyPos.deltaX)s.__dragCopyPos.deltaX=s.__dragCopyPos.left-e;if(!s.__dragCopyPos.deltaY)s.__dragCopyPos.deltaY=s.__dragCopyPos.top-i;e+=s.__dragCopyPos.deltaX;i+=s.__dragCopyPos.deltaY}r.style.left=e+"px";r.style.top=i+"px"}},onbxdraghout:function(e,t,i){},onbxdestdraghover:function(e){if(!e||!e.hasAttribute("bx-bxu-item-id")||!this.items.hasItem(e.getAttribute("bx-bxu-item-id")))return;var i=t.proxy_context;t.addClass(i,"bx-drag-over");return true},onbxdestdraghout:function(){var e=t.proxy_context;t.removeClass(e,"bx-drag-over");return true},onbxdestdragfinish:function(e){var i=t.proxy_context;t.removeClass(i,"bx-drag-over");if(i==e||!t.hasClass(e,"bx-drag-draggable"))return true;var s=e.getAttribute("bx-bxu-item-id");if(!this.items.hasItem(s))return;var r=i.parentNode,d=r.childNodes.length,a,o,l,n;for(n=0;n<d;n++){if(r.childNodes[n]==i)i.number=n;else if(r.childNodes[n]==e)e.number=n;if(e.number>0&&i.number>0)break}if(this.itForUpload.hasItem(s)){a=i.number<=e.number?"beforeItem":i.nextSibling?"afterItem":"inTheEnd";o=null;if(a!="inTheEnd"){for(n=i.number+(a=="beforeItem"?0:1);n<d;n++){if(this.itForUpload.hasItem(r.childNodes[n].getAttribute("bx-bxu-item-id"))){o=r.childNodes[n].getAttribute("bx-bxu-item-id");break}}if(o===null)a="inTheEnd"}l=this.itForUpload.removeItem(e.getAttribute("bx-bxu-item-id"));if(a!="inTheEnd")this.itForUpload.insertBeforeItem(l.id,l,o);else this.itForUpload.setItem(l.id,l)}a=i.number<=e.number?"beforeItem":i.nextSibling?"afterItem":"inTheEnd";o=null;if(a!="inTheEnd"){for(n=i.number+(a=="beforeItem"?0:1);n<d;n++){if(this.items.hasItem(r.childNodes[n].getAttribute("bx-bxu-item-id"))){o=r.childNodes[n].getAttribute("bx-bxu-item-id");break}}if(o===null)a="inTheEnd"}l=this.items.removeItem(e.getAttribute("bx-bxu-item-id"));if(a!="inTheEnd")this.items.insertBeforeItem(l.id,l,o);else this.items.setItem(l.id,l);e.parentNode.removeChild(e);if(i.number<=e.number){i.parentNode.insertBefore(e,i)}else if(i.nextSibling){i.parentNode.insertBefore(e,i.nextSibling)}else{for(n=0;n<d;n++){if(r.childNodes[n]==i)i.number=n;else if(r.childNodes[n]==e)e.number=n}if(i.number<=e.number){i.parentNode.insertBefore(e,i)}else{i.parentNode.appendChild(e)}}t.onCustomEvent(i,"onFileOrderIsChanged",[i.id,i,this.caller]);t.onCustomEvent(this.uploader,"onQueueIsChanged",[this,"sort",i.id,i]);return true},deleteItem:function(i,s){var r=this.getItem(i),d;if(r&&(!this.placeHolder||(d=r.node)&&d)){if(!!d){if(!!e["jsDD"]){d.onmousedown=null;d.onbxdragstart=null;d.onbxdragstop=null;d.onbxdrag=null;d.onbxdraghout=null;d.onbxdestdraghover=null;d.onbxdestdraghout=null;d.onbxdestdragfinish=null;d.__bxpos=null;e.jsDD.arObjects[d.__bxddid]=null;delete e.jsDD.arObjects[d.__bxddid];e.jsDD.arDestinations[d.__bxddeid]=null;delete e.jsDD.arDestinations[d.__bxddeid]}t.unbindAll(d);if(s["replaced"]!==true)d.parentNode.removeChild(d)}this.items.removeItem(i);this.itUploaded.removeItem(i);this.itFailed.removeItem(i);this.itForUpload.removeItem(i);t.onCustomEvent(this.uploader,"onQueueIsChanged",[this,"delete",i,s]);return true}return false},reinitItem:function(i,s){var r,d;if(!!this.placeHolder&&this.items.hasItem(i)&&(r=t(i+"Item"))&&r){d=s.makeThumb();if(t.type.isNotEmptyString(d)){if(this.thumb.tagName=="TR"){d=d.replace(/[\n\t]/gi,"").replace(/^(\s+)(.*?)/gi,"$2").replace(/(.*?)(\s+)$/gi,"$1");if(!!d["trim"])d=d.trim();var a=function(e,t,i){var s=r.insertCell(-1),d={colspan:true,headers:true,accesskey:true,class:true,contenteditable:true,contextmenu:true,dir:true,hidden:true,id:true,lang:true,spellcheck:true,style:true,tabindex:true,title:true,translate:true},a;s.innerHTML=i;t=t.split(" ");while((a=t.pop())&&a){a=a.split("=");if(a.length==2){a[0]=a[0].replace(/^(\s+)(.*?)/gi,"$2").replace(/(.*?)(\s+)$/gi,"$1").replace(/^["'](.*?)["']$/gi,"$1");a[1]=a[1].replace(/^(\s+)(.*?)/gi,"$2").replace(/(.*?)(\s+)$/gi,"$1").replace(/^["'](.*?)["']$/gi,"$1");if(d[a[0]]===true)s.setAttribute(a[0],a[1]);else s[a[0]]=a[1]}}return""},o=/^<td(.*?)>(.*?)<\/td>/i;e.data1=d;while(o.test(d))d=d.replace(o,a)}else{r.innerHTML=d}}else if(t.type.isDomNode(d)){while(t(r.firstChild)){t.remove(r.firstChild)}t.adjust(r,{children:[d]})}t.onCustomEvent(this.uploader,"onFileIsAppended",[s.id,s,this.caller]);t.onCustomEvent(s,"onFileIsAppended",[s.id,s,this.caller])}},clear:function(){var e;while((e=this.items.getFirst())&&!!e)this.deleteItem(e.id,e)},restoreFiles:function(e,i,s){e.reset();var r,d,a;while((r=e.getNext())&&r){a=this.itFailed.hasItem(r.id);if(i===true){this.itFailed.removeItem(r.id)}if(!this.items.hasItem(r.id)||this.itFailed.hasItem(r.id)){continue}if(s===true||s!==false&&a){delete r["uploadStatus"];delete r.file["uploadStatus"];delete r.file["firstChunk"];delete r.file["package"];delete r.file["packages"];if(r.file["copies"]){r.file["copies"].reset();while((d=r.file["copies"].getNext())&&d){delete d["uploadStatus"];delete d["firstChunk"];delete d["package"];delete d["packages"]}r.file["copies"].reset()}r["restored"]=s===true?"Y":"C"}else{if(a){if(r.file["package"]){r.file["package"]--}if(r.file["copies"]){r.file["copies"].reset();while((d=r.file["copies"].getNext())&&d){delete d["uploadStatus"];delete d["firstChunk"];delete d["package"];delete d["packages"]}r.file["copies"].reset()}}r["restored"]="C"}this.itUploaded.removeItem(r.id);this.itForUpload.setItem(r.id,r);t.onCustomEvent(r,"onUploadRestore",[r])}}};return i})(window);
//# sourceMappingURL=queue.map.js